package com.yzy.fly.service.util;

import com.google.common.collect.Maps;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.ArrayUtils;

import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.*;

@Slf4j
public class FieldInvokeUtil {

    public static List<Field> findFieldsByAnnotationPresent(Class clz,Class annotation){
        List<Field> fields  = new ArrayList<>();
        Field[] declaredFields = clz.getDeclaredFields();
        if (ArrayUtils.isNotEmpty(declaredFields)) {
            for (int i = 0; i < declaredFields.length; i++) {
                Field declaredField = declaredFields[i];
                if (declaredField.isAnnotationPresent(annotation)) {
                    fields.add(declaredField);
                }
            }
        }
        return fields;
    }

}
